﻿using UnityEngine;

namespace Model
{
    public static class PathHelper
    {

#if UNITY_EDITOR
        /// <summary>
        /// 打包存放的路径
        /// </summary>
        public readonly static string buildPath = Application.streamingAssetsPath + "/Bundles";

        /// <summary>
        /// 各个平台包，存放路径。
        /// </summary>
        public readonly static string windowTargetPath = buildPath + "/Windows";
        public readonly static string androidTargetPath = buildPath + "/Android";

        public readonly static string ResServerPath = @"../Release/";

        /// <summary>
        /// 需要设置标签的路径
        /// </summary>
        public readonly static string resPath = Application.dataPath + "/Bundles";

#endif
        /// <summary>
        /// 热更新资源文件
        /// </summary>
        public static string AppHotfixResPath
        {
            get
            {
                string game = Application.productName;
                string path = AppResPath;
                if (Application.isMobilePlatform)
                {
                    path = $"{Application.persistentDataPath}/{game}/";
                }
                return path;
            }
        }

        /// <summary>
        /// 获取当前运行的平台
        /// </summary>
        /// <returns></returns>
        public static string GetCurrentPlatform()
        {
            switch (Application.platform)
            {
                case RuntimePlatform.WindowsPlayer:
                case RuntimePlatform.WindowsEditor:
                    return "Windows";
                case RuntimePlatform.IPhonePlayer:
                    return "IOS";
                case RuntimePlatform.Android:
                    return "Android";
                default:
                    return "";
            }
        }

        /// <summary>
        /// 应用程序内部资源路径存放路径
        /// </summary>
        public static string AppResPath
        {
            get
            {
                string path = string.Empty;
                switch (Application.platform)
                {
                    case RuntimePlatform.Android:
                        path = $"jar:file://{Application.dataPath}!!/assets/Bundles/";
                        break;
                    case RuntimePlatform.IPhonePlayer:
                        path = $"{Application.dataPath}/Raw/Bundles/";
                        break;
                    default:
                        path = $"{Application.dataPath}/StreamingAssets/Bundles/" + GetCurrentPlatform() + "/";
                        break;
                }
                return path;
            }
        }

    }
}